/*
 *            DO YOU WHAT THE WANT TO PUBLIC LICENSE
 *
 * Everyone is permitted to copy and distribute verbatim or modified
 * copies of this license document, and changing it is allowed as long
 * as the name is changed.
 *
 *           DO YOU WHAT THE WANT TO PUBLIC LICENSE
 *  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 *
 * 0. You just DO WHAT YOU WANT TO DO.
 */

package com.iurmfy.deskpet;

import javax.swing.*;
import java.awt.*;

// 用于存放图片
/**
 * This class will show the pet image
 * used JComponent to show this result
 *
 * @author iurmfy
 * @version 1.0.0
 */
public class PetStage extends JComponent
{
    // 用户指定图片
    private final Image image;

    // 用户指定缩放倍数
    private final int multiple;

    /**
     * This method will create img
     *
     * @param image Path to the picture.
     * @param multiple Image to the scale.
     */
    public PetStage(Image image, int multiple)
    {
        this.image = image;
        this.multiple = multiple;

        setSize(image.getWidth(this) / multiple,
                image.getHeight(this)/multiple);
    }

    // 绘制图片
    @Override
    protected void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;


        // 绘制大小
        g2.drawImage(image, 0, 0,
                image.getWidth(this) /multiple,
                image.getHeight(this) / multiple,
                this );
    }
}
